package com.lhkj.ct.meta.modules.gauge.model.entity;

import com.baomidou.mybatisplus.annotation.TableField;
import com.baomidou.mybatisplus.annotation.TableId;
import com.fasterxml.jackson.annotation.JsonProperty;
import com.lhkj.ct.meta.modules.gauge.common.enums.GaugeType;
import com.lhkj.ct.meta.modules.gauge.common.enums.QuestionType;
import com.lhkj.ct.meta.modules.gauge.validation.QuestionGroupSequenceProvider;
import io.swagger.annotations.ApiModel;
import io.swagger.annotations.ApiModelProperty;
import lombok.Data;
import lombok.EqualsAndHashCode;
import org.hibernate.validator.group.GroupSequenceProvider;

import javax.validation.Valid;
import javax.validation.constraints.NotEmpty;
import javax.validation.constraints.NotNull;
import java.io.Serializable;
import java.util.List;
import java.util.Objects;

/**
 * <p>
 *
 * </p>
 *
 * @author jobob
 * @since 2023-10-08
 */
@Data
@EqualsAndHashCode(callSuper = false)
@ApiModel(value="TblQuestion对象", description="")
@GroupSequenceProvider(QuestionGroupSequenceProvider.class)
public class TblGaugeQuestion implements Serializable {

    private static final long serialVersionUID = 1L;

    @TableId
    @ApiModelProperty(value = "题目id")
    private String qutId;

    @ApiModelProperty(value = "题目内容")
//    @NotBlank(message = "请设置题目内容")
    private String qutContent;

    @ApiModelProperty(value = "题目内容")
//    @NotBlank(message = "请设置题目内容")
    private String qutPicture;

    @ApiModelProperty(value = "量表/问卷编号", notes = "后端处理")
    private String gaugeId;

    @ApiModelProperty(value = "测量类型 1.量表 2.问卷", notes = "后端处理")
    private GaugeType gaugeType;

    @ApiModelProperty(value = "作答提示")
    private String prompt;

    @ApiModelProperty(value = "题目类型")
    @NotNull(message = "题目类型不能为NULL")
    private QuestionType type;

    @ApiModelProperty(value = "排序", notes = "后端处理")
    private Integer qutSort;

    @ApiModelProperty(value = "表单name属性", notes = "后端处理")
    private String name;

    @ApiModelProperty(value = "是否必填")
    @NotNull(message = "请设置题目是否必填")
    private Boolean required;

    @ApiModelProperty(value = "题目选项")
    @TableField(exist = false)
    @NotEmpty(message = "请设置题目选项", groups = {option.class})
    @Valid
    private List<TblGaugeOption> options;

    /**
     * 保存选项逻辑时匹配题目vId
     */
    @TableField(exist = false)
    @ApiModelProperty(value = "json唯一id")
    @JsonProperty("vId")
    private String vId;

    public boolean compare(Object o) {
        if (this == o) return true;
        if (o == null || getClass() != o.getClass()) return false;
        TblGaugeQuestion that = (TblGaugeQuestion) o;
        return Objects.equals(qutId, that.qutId) &&
                Objects.equals(qutContent, that.qutContent) &&
                Objects.equals(qutPicture, that.qutPicture) &&
                Objects.equals(gaugeId, that.gaugeId) &&
                gaugeType == that.gaugeType &&
                Objects.equals(prompt, that.prompt) &&
                Objects.equals(type, that.type) &&
                Objects.equals(qutSort, that.qutSort) &&
                Objects.equals(name, that.name) &&
                Objects.equals(vId, that.vId) &&
                Objects.equals(required, that.required);
    }

    public interface option{

    }
}
